package servlet;

import java.io.IOException;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import entities.Customer;


/**
 * Servlet implementation class HonorRollServlet
 */
public class ManageUserEditServlet extends HttpServlet 
{
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public ManageUserEditServlet() 
    {
        super();
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException 
	{
		/*HttpSession session = request.getSession();
		Customer customer = createCustomer(request);
		
		if(customer.getUserID().equalsIgnoreCase(null)){
			customer.setUserID(" ");
			customer.setLname(" ");
			customer.setName(" ");
			customer.setPassword(" ");
		}
			session.setAttribute("customer", customer);*/
		String addr =null;
			addr = "./html/admin-users-edit.jsp";
		
		/*CustomerServiceFactory factory = CustomerServiceFactory.getFactory(ServletInitParams.getServiceFactoryType(this));
		CustomerService service = factory.getInstance();
		List<Customer> customers =null;
				
		customers = service.customersList();
		//customers.get(index).
		session.setAttribute("customers", customers);*/
		
		RequestDispatcher dispatcher = request.getRequestDispatcher(addr);
		dispatcher.forward(request, response);
	}
	private Customer createCustomer(HttpServletRequest request) {
		String id = getInitParameter("id");
		String lname = getInitParameter("lname");
		String fname = getInitParameter("fname");
		Customer customer = null;
		customer = Customer.newInstance(id, fname, lname, "", null, "", "", "", "", "", "", "");
		return customer;
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException 
	{
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
